package com.ruoyi.swla2.service.impl;

import java.time.LocalDate;
import java.util.List;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.ruoyi.swla2.model.FreezeDataQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.swla2.mapper.TerminalsFreezeMapper;
import com.ruoyi.swla2.domain.TerminalsFreeze;
import com.ruoyi.swla2.service.ITerminalsFreezeService;

/**
 * 大日冻结数据Service业务层处理
 *
 * @author gdqt
 * @date 2023-08-30
 */
@Service
public class TerminalsFreezeServiceImpl implements ITerminalsFreezeService {
    @Autowired
    private TerminalsFreezeMapper terminalsFreezeMapper;

    /**
     * 查询大日冻结数据
     *
     * @param tenantId 大日冻结数据主键
     * @return 大日冻结数据
     */
    @Override
    public TerminalsFreeze selectTerminalsFreezeByTenantId(String tenantId) {
        return terminalsFreezeMapper.selectTerminalsFreezeByTenantId(tenantId);
    }

    /**
     * 查询大日冻结数据列表
     *
     * @param terminalsFreeze 大日冻结数据
     * @return 大日冻结数据
     */
    @Override
    public List<TerminalsFreeze> selectTerminalsFreezeList(TerminalsFreeze terminalsFreeze) {
        return terminalsFreezeMapper.selectTerminalsFreezeList(terminalsFreeze);
    }

    /**
     * 新增大日冻结数据
     *
     * @param terminalsFreeze 大日冻结数据
     * @return 结果
     */
    @Override
    public int insertTerminalsFreeze(TerminalsFreeze terminalsFreeze) {
        return terminalsFreezeMapper.insertTerminalsFreeze(terminalsFreeze);
    }

    /**
     * 修改大日冻结数据
     *
     * @param terminalsFreeze 大日冻结数据
     * @return 结果
     */
    @Override
    public int updateTerminalsFreeze(TerminalsFreeze terminalsFreeze) {
        return terminalsFreezeMapper.updateTerminalsFreeze(terminalsFreeze);
    }

    /**
     * 批量删除大日冻结数据
     *
     * @param tenantIds 需要删除的大日冻结数据主键
     * @return 结果
     */
    @Override
    public int deleteTerminalsFreezeByTenantIds(String[] tenantIds) {
        return terminalsFreezeMapper.deleteTerminalsFreezeByTenantIds(tenantIds);
    }

    /**
     * 删除大日冻结数据信息
     *
     * @param tenantId 大日冻结数据主键
     * @return 结果
     */
    @Override
    public int deleteTerminalsFreezeByTenantId(String tenantId) {
        return terminalsFreezeMapper.deleteTerminalsFreezeByTenantId(tenantId);
    }

    @Override
    public List<TerminalsFreeze> selectTerminalsFreezeByQueryModel(FreezeDataQueryModel model) {
//        LocalDate start = StrUtil.isEmpty(model.getStartDate()) ? LocalDate.now().minusDays(15) : LocalDate.parse(model.getStartDate());
//        LocalDate end = StrUtil.isEmpty(model.getEndDate()) ? LocalDate.now().minusDays(1) : LocalDate.parse(model.getEndDate());
//        model.setStartDate(start.toString());
//        model.setEndDate(end.toString());
//        System.out.println(JSON.toJSONString(model));
        return terminalsFreezeMapper.selectTerminalsFreezeByQueryModel(model);
    }
}
